class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-07-10",
      revision: "efd4a69880a2f7540442356f3aef233769b1e6a1"
  version "2021-07-10"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "383c4ff0ebe4f206144e7a3f0c0aba8dcb6653332a1878e56cd0e14f821a86fe"
    sha256 cellar: :any_skip_relocation, big_sur:       "670d0859b5dad27b3e1d981d04cd91c12dd63cf1972db26f5aef38c28fec773d"
    sha256 cellar: :any_skip_relocation, catalina:      "b8b8f6dccf6afc67aece2223f1b3e0db62db63ee81e8c215e463cc28023892a8"
    sha256 cellar: :any_skip_relocation, mojave:        "036025ff1f8bbc0a880d260bcbab91998c2e8662af4352d0e504d9853aa717e5"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
